<?php







$link = mysql_connect ( '203.171.236.137', 'wgz', 'ad369/*-');
if (! $link) {
	die ( 'Could not connect: ' . mysql_error () );
}
mysql_query ( "SET NAMES utf8", $link );

$sql = "SELECT uin, count(uin) as cnum from kkyoo_gift.ek_deposit where flag = 4 and DATE_FORMAT(updated, '%Y-%m-%d') = '2009-10-15' 
	group by uin 
  order by cnum desc; ";

$dsd = 0;
$re = mysql_query ( $sql, $link );	
if (empty($re)){
	echo "dasdsadas";
}else 

while ( $row = mysql_fetch_assoc($re) ) {
	if ((int)$row['cnum'] > 1){
		$sql2 = "SELECT sum(sum) as  nnd from kkyoo_gift.ek_deposit where uin = {$row['uin']} and flag = 4 and DATE_FORMAT(updated, '%Y-%m-%d') = '2009-10-15';";
		$re2 = mysql_query ( $sql2, $link );
		$row2 = mysql_fetch_assoc($re2);
		$dsd += (int)$row2['nnd'];
		echo "ID: {$row['uin']}  -》 {$row2['nnd']} <br />\t\n";
		mysql_free_result($re2);
	}
}
mysql_close ( $link );

echo "<br /> ==== SUM: {$dsd}";

?>